﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Common;

namespace CNCSoft.ErpApps.TMS.longACSS
{
    public partial class frmPhanTramChuyenCanHocVien : Form
    {
        SqlConnection conn = new SqlConnection(GlobalVariable.WSInfo.ConnectionString);
        DataSet ds = new DataSet();
        string _invoicenumber, _makhoahoc;

        public frmPhanTramChuyenCanHocVien()
        {
            InitializeComponent();
        }

        public frmPhanTramChuyenCanHocVien(string invoicenumber, string makhoahoc)
        {
            _invoicenumber = invoicenumber;
            _makhoahoc = makhoahoc;
            InitializeComponent();
        }

        private void frmPhanTramChuyenCanHocVien_Load(object sender, EventArgs e)
        {
            LoadControl();
        }

        #region "Coding"
        private void LoadControl()
        {
            LoadData();
        }

        private void LoadData()
        {
            try
            {
                LoadPhanTramChuyenCan(_invoicenumber, _makhoahoc);
                gridControl_Data.DataSource = ds.Tables["TableChuyenCan"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void LoadPhanTramChuyenCan(string invoicenumber, string makhoahoc)
        {
            try
            {
                if (ds.Tables["TableChuyenCan"] != null)
                    ds.Tables["TableChuyenCan"].Clear();
                string sql = @"usp_PhanTramChuyenCanByInvNumAndMaKhoaHoc @invoicenumber = '" + invoicenumber + @"', @makhoahoc = '" + makhoahoc + @"'";
                SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                da.Fill(ds, "TableChuyenCan");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #endregion
    }
}
